<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BDDUser
 *
 * @author Rolland
 */
require 'User.php';
class BDDUser extends User{
    
    function __construct(){
        
    }
    
    static public function all(){
        try{
            $db= getPdo();
            $tab = array();
            
            $rep = $db->query("select * from user " );
            while($data =$rep->fetch()){
                $tab[$data['id']]=new User($data['id'], $data['nom'], $data['pwd']);
            }
            $rep->closeCursor();
            return $tab;
        }catch(Exception $e){
            die('erreur requete'.$e->getMessage());
        }
    } 
    
    static public function getEntrepots(){
        try{
            $db= getPdo();
            $tab = array();
            
            $rep = $db->query("select * from entrepot " );
            while($data =$rep->fetch()){
                $tab[$data['id']]=new Entrepot($data['id'], $data['site']);
            }
            $rep->closeCursor();
            return $tab;
        }catch(Exception $e){
            die('erreur requete'.$e->getMessage());
        }
    } 
}

?>
